<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="model.pojo.*, java.util.*, model.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <%
            request.setAttribute("pageTitle", "User Listing");
            User cu = (User) request.getAttribute("currentUser");
            boolean thereAreMorePages = (Boolean) request.getAttribute("thereAreMorePages");
            int thisSetIsEndingAt = (Integer) (request.getAttribute("endingAt"));
            List<User> users = (List<User>) request.getAttribute("users");
            Map<User, UserProfile> user2userProfile = (Map<User, UserProfile>) request.getAttribute("user2userProfile");
    %>
    <%@ include file="/WEB-INF/jspf/header.jspf"%>
    <div class="portion"> 
        <table border="0">
            <tbody>
                <%
            for (User u : users) {
                UserProfile up = user2userProfile.get(u);
                %>
                <tr>
                    <td>
                        <img src="<%=up.getPhotoLink()%>">
                        <br>
                        <a class="minor" href="showProfile.do?userID=<%=u.getUserID()%>"><%=u.getDisplayName()%></a>
                        <br>
                        <a class="minor" href="posts.do?user=<%=u.getUserID()%>"><%=u.getDisplayName()%>'s Blog</a>
                    </td>
                </tr>
                <%
                if (u != null && (u.equals(cu) || fbUser.isAdmin(cu))) {
                %>
                <tr>
                    <td>
                        <a class="minor" href="deleteUser.do?user=<%=u.getUserID()%>">Delete this Account</a>
                    </td>
                </tr>
                <%
                }
            }

            if (thereAreMorePages) {
                %>
                <tr>
                    <td>
                        <a class="minor" href="getUserListing.do?startingFrom=<%=thisSetIsEndingAt%>">Go To Next Page</a>
                    </td>
                </tr>
                <%
            }
                %>
            </tbody>
        </table>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf"%>
</html>
